from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import skus, orders, permissions, groups
from .views import statistical,users,specs,images
urlpatterns = [
    # JWT 登录
    url(r'^authorizations/$', obtain_jwt_token),
    # 用户总数统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 当天注册用户数统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 当天登录用户统计
    url(r'^statistical/day_active/$', statistical.UserDayCountActiveView.as_view()),
    # 当天下单用户统计
    url(r'^statistical/day_orders/$', statistical.UserDayCountordersView.as_view()),
    # 月用户注册统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 商品分类访问量统计
    url(r'^statistical/goods_day_views/$', statistical.GoodsTypeCountView.as_view()),
    # 用户数据操作
    url(r'^users/$', users.UserView.as_view()),
    # 商品规格表路由匹配
    # 获取spu商品
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get':'simple'})),
    # 图片表路由匹配
    # 获取sku商品
    # url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),
    url(r'^skus/simple/$', images.ImageView.as_view({'get':'simple'})),

    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # 获取权限分类
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_types'})),
    # 获取分组中的所有权限
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
]

# 规格表路由匹配
router=DefaultRouter()
router.register('goods/specs',specs.SpecsView,base_name='spec')
urlpatterns += router.urls

# 图片表路由匹配
router=DefaultRouter()
router.register('skus/images',images.ImageView,base_name='image')
urlpatterns += router.urls

# sku表路由匹配
router=DefaultRouter()
router.register('skus',skus.SKUView,base_name='sku')
urlpatterns += router.urls

# 订单表路由匹配
router=DefaultRouter()
router.register('orders',orders.OrderView,base_name='order')
urlpatterns += router.urls

# 权限表路由匹配
router=DefaultRouter()
router.register('permission/perms',permissions.PermissionView,base_name='permission')
urlpatterns += router.urls

# 分组表路由匹配
router=DefaultRouter()
router.register('permission/groups',groups.GroupView,base_name='group')
urlpatterns += router.urls